{include file='header.tpl'}
{literal}
<script language="javascript">

$(document).ready(function(){
{/literal}
	init_container_ad('{$data.keywords}');
{literal}
	comment(1);
});

function comment(page)
{
	var URL = 'comment.php';
	var id  = 'container-comment';
{/literal}
	var newsid = {$data.id}
{literal}
	$.ajax({
		url:URL,
		dataType: 'json',
		data: {newsid:newsid,page:page},
		success: function(data, status){
			comment_init( data, id );
		}
	});	
}

function docomment(op)
{
	var comment = $('#comment').val();
	var URL = 'comment.php';
	var id  = 'container-comment';
	var ano = $('input[name=anonymous]').attr('checked');
	if(comment == '' || comment.length<10) {
		alert('评论太短,,');
		return false;
	}
{/literal}
	var newsid = {$data.id}
	{if $sess.user.username == ''}alert('请先登陆');return false;{/if}
{literal}
	$.ajax({
		url:URL,
		dataType: 'json',
		data: {comment:comment, newsid:newsid, anonymous:ano, op:op},
		success: function(data, status){
			comment_init( data, id );
			$('#comment').val('');
		}
	});
	return false;
}
function comment_init(data,id)
{
	var html = '<dl>';
	var username = '';
	var obj = data.data;
	for( var i in obj) {
		username = obj[i].username;
		if( obj[i].anonymous == 1 ) {
			username = '爱淘网友';
		}
		html += '<dt>';
		html += '<p class="ct"><b>'+username+'</b> 发表于:<span class="showtime">'+obj[i].created+'</span></p>';
		html += '<p class="cc">'+obj[i].comment+'</p>';
		html += '</dt>';
	}
	html += '</dl>';
	html += data.pagination;
	$('#'+id).html(html);
	$('#total-comment').html('共有'+data.total+'条评论');
}
</script>
{/literal}
<div id="container">
	<div class="left-container">
		<div class="left">
    	<div>
        	<h1 style="font-size:22px; margin-top:20px;">{$data.title}</h1>
            <p>来源:{$data.copyfrom} 作者:{$data.author} 发布时间:{$data.created|date_format:"%Y-%m-%d" }</p>
        </div>
        <div style="border-bottom:1px dashed #bcc8de;">  </div>
    	<div>{$data.content}</div>
        <div class="paginate">
        	{$pagination}
        </div>
        <div class="clear"></div>
    	</div>
        <div class="clear"></div>
        <div id="container-ad" class="container-ad-box">
        </div>
    	<div class="clear"></div>
    	<div class="comment">
    		<div style="border-bottom:1px solid #CCC; width:95%; margin-left:auto; margin-right:auto;">
            	<h2 style="line-height:30px; margin-top:10px; font-size:16px; text-align:left;">网友评论</h2>
                <p style="text-align:right; padding-right:20px;" id="total-comment">共有0条评论</p>
            </div>
            <div style="width:95%; margin-left:auto; margin-right:auto;" id="container-comment">
            </div>
            <div style="width:95%; margin-left:auto; margin-right:auto;">
            	<form action="/" name="commentForm" method="post" onsubmit="return docomment('add');">
            	<textarea cols="90" rows="6" style="width:550px;" name="comment" id="comment"></textarea><br />
                {if $sess.user}亲爱的<b>{$sess.user.username}</b><input type="checkbox" name="anonymous" id="anonymous" value="1" />匿名发表{else}请<a href="login.php">登陆</a>后发表评论{/if} <button name="submit" type="submit" >发表评论</button>
                </form>
            </div>
    	</div>
    </div>
	<div class="right">
    	<!--Ad-->
    	<div>
    	<embed src="http://a.alimama.cn/widget/yr1/yr1fixed_300_250.swf" flashvars="catid=50006274&count=20&sz=37&type=1&i=mm_11050383_0_0" width="300" height="250" quality="high" wmode="transparent" bgcolor="#ffffff" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
        </div>
        <!--End Ad-->
        <div class="recomment">
        	<p class="title"><b>推荐资讯</b></p>
            <ul>
            {db_fetchpage table="news" items="*" orderby="id ASC" page="1" pagesize="10" varname="arr"}
            {section name=loop loop=$arr}
            
            	<li><a href="newsdetail.php?id={$arr[loop].id}">{$arr[loop].title}</a></li>
            {/section}
            </ul>
        </div>
    	<!--Ad-->
    	<div style="margin-top:10px;">
    	<embed src="http://a.alimama.cn/widget/yr1/yr1fixed_300_250.swf" flashvars="catid=50006274&count=20&sz=37&type=1&i=mm_11050383_0_0" width="300" height="250" quality="high" wmode="transparent" bgcolor="#ffffff" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
        </div>
        <!--End Ad-->        
    </div>
	<div style="clear:both;"></div>
</div>

{include file='footer.tpl'}
